import { mapActions, mapState } from 'vuex';
import i18n from '@/i18n-setup';

export default {
  data() {
    return {};
  },
  computed: {
    ...mapState(['theme']),
  },
  methods: {
    ...mapActions('common', ['openDialog', 'closeDialog']),
    copy(data) {
      this.$copyText(data)
        .then(() => { this.$message.success(i18n.locale === 'zh-CN' ? 'success' : 'success'); });
    },
    toFixed(amount = 0, fix = 6) {
      if (amount === '0') return amount;
      return Number(String(amount).match(new RegExp(`^\\d+(?:\\.\\d{0,${fix}})?`)) || 0);
    },
  },
};
